/*
 * SliderDelegate.h  0.4.0 / Dec 05, 2010
 *
 * Copyright (c) 2010 - 2011, cute4j.com and contributors.
 *
 * This software is licensed under the LGPL version 2.1 license.
 * A copy of this license is included in the file LICENSE-LGPL.txt.
 */
#ifndef SLIDERDELEGATE_H
#define SLIDERDELEGATE_H

#include "Cute4jSwing.h"

#include "ComponentDelegate.h"

// SliderDelegate Class. -------------------------------------------------------

/*!
 * \brief Slider Delegate.
 *
 * \author Slobodan Vrkacevic
 * \version 0.4.0
 */
class CUTE4J_EXPORT SliderDelegate : public ComponentDelegate
{
  Q_OBJECT
protected:
  SliderDelegate(JNIEnv *env, jobject obj);
public slots: // native calls
  void setModel(JNIEnv *env, jint minimum, jint maximum, jint value);
  void setValue(JNIEnv *env, jint value);
  void setMinimum(JNIEnv *env, jint minimum);
  void setMaximum(JNIEnv *env, jint maximum);
  void setOrientation(JNIEnv *env, jint orientation);
  void setTickPosition(JNIEnv *env, jint tickPosition);
  void setTickSpacing(JNIEnv *env, jint tickSpacing);
public: // native calls
  static void initialize(JNIEnv *env, jclass cls);
  static jlong newInstance(JNIEnv *env, jobject obj);
public: // native callbacks
  void valueChanged(jint value);
  void valueIsAdjusting(jboolean adjusting);
protected slots:
  void valueChangedSlot(int value);
  void sliderPressedSlot();
  void sliderReleasedSlot();
public:
  inline QSlider *qSlider() const;
private:
  static jmethodID sm_valueChangedMID;
  static jmethodID sm_valueIsAdjustingMID;
};

// SliderDelegate :: Public Inline Member Function. ----------------------------

/*!
 * \brief Returns QSlider adaptee.
 *
 * \return QSlider adaptee
 */
inline QSlider *SliderDelegate::qSlider() const
{
  return static_cast<QSlider *>(qObject());
}

// Macro Definition. -----------------------------------------------------------

#define SLIDER_DELEGATE (reinterpret_cast<SliderDelegate *>(delegate))

#endif // SLIDERDELEGATE_H
